/**
 * @FileName: CGlibProxyFactory.java
 * @Package: com.ziroom.sms.std.proxy
 * @author liusq23
 * @created 2017/3/10 下午1:39
 * <p>
 * Copyright 2015 ziroom
 */
package com.ziroom.sms.std.proxy;

import com.ziroom.sms.std.rpc.RpcInvocationHandler;
import net.sf.cglib.proxy.Enhancer;

import java.lang.reflect.InvocationTargetException;

/**
 * <p></p>
 * <p>
 * <PRE>
 * <BR>	修改记录
 * <BR>-----------------------------------------------
 * <BR>	修改日期			修改人			修改内容
 * </PRE>
 *
 * @author liusq23
 * @version 1.0
 * @since 1.0
 */
public class CGlibProxyFactory implements ProxyFactory {

    @Override
    public <T> T getProxy(Class<T> tClass, RpcInvocationHandler invocationHandler) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(tClass);
        enhancer.setCallback(invocationHandler);
        return (T) enhancer.create();
    }
}

